package ooday05;
/** static的演示 */
public class StaticDemo {
    public static void main(String[] args) {
        StaticVar o1 = new StaticVar();
        o1.show();
        StaticVar o2 = new StaticVar();
        o2.show();
        StaticVar o3 = new StaticVar();
        o3.show();
        System.out.println(StaticVar.b); //静态变量通过类名点来访问
        System.out.println(o1.a); //实例变量通过对象打点来访问

        StaticBlock o4 = new StaticBlock(); //加载类时自动执行静态块，静态块只执行一次
        StaticBlock o5 = new StaticBlock();
        StaticBlock o6 = new StaticBlock();

        StaticMethod.test(); //静态方法，通过类名点来访问
    }
}
